I used a previous article to explain how to dynamically add a line of technology.
Function checkserialnum (Whatid, what, retailer, curr, whse){If (form1.salesman. value = ""){Alert ("select a store first ");Return;}If (event. keycode = 13){VaR oxmlhttp = new activexobject ("Microsoft. XMLHTTP ");
Oxmlhttp. Open ("Post", "qrysn. asp? Serialnum = "+ What +" retailer = "+ retailer +" curr = "+ curr +" whse = "+ whse, false );
Oxmlhttp. Send ();If (Une
processes are analyzed based on the output results.
Class SerialNum
public class SerialNum {// The next serial number to be assigned private static int nextSerialNum = 0; public static ThreadLocal serialNum = new ThreadLocal() { protected synchronized Object initialValue() { return new Integer(nextSerialNum++); } }; public st
1, in multithreaded programming, sometimes need to automatically generates each start line into a unique identity, this time, through a threadlocal variable to save the identity of each thread is the most effective, most convenient way.2. ThreadLocal instances are typically private static fields in a class3, in the construction of threadlocal, by overriding the subclass of the method to rewrite the sequence number. The purpose of generating the serial number for each thread is thus achieved.Impo
class Serialnum {//The next serial number to be assigned private static int nextserialnum = 0; public static ThreadLocal Serialnum = new ThreadLocal () { protected synchronized Object InitialValue () { return NE W Integer (nextserialnum++); } }; public static int Get () { return ((Integer) (Serialnum.get ())). Intvalue (); public static void Set (int val) {
= thread. currentthread ();Object o = values. Get (curthread );If (O = NULL ! Values. containskey (curthread )){O = initialvalue ();Values. Put (curthread, O );}Return O;}
Public void set (Object newvalue ){Values. Put (thread. currentthread (), newvalue );}
Public object initialvalue (){Return NULL;}}
Of course, this is not an industrial implementation, but the general idea of threadlocal implementation in JDK is similar to this.
Threadlocal usage
If you want to initialize other values for the
Java objects are instantiated in the following ways:1. Use new2. Factory mode3. Reflection4. Clone () method5. Deserialization mode/**
implementing Cloneable and Serializable interfaces
*/ public class book implements Cloneable, Serializable { Private static final long serialversionuid = 1L; Private Integer Serialnum;//serial number private String name;//Library name Public book () { System.out.println ("default constructor "); }
, this is not an industrial implementation, but the general idea of threadlocal implementation in JDK is similar to this.
Threadlocal usage
If you want to initialize other values for the thread local variable, You need to implement the threadlocal subclass and override this method. Generally, a internal Anonymous class is used to subclass threadlocal. For example, in the following example, the serialnum class assigns an serial number for each clas
Generally, the serial number of an application is required to generate the last several consecutive strings according to certain rules. below is the code used in my project to generate the serial number, in which the lock mechanism is used.
Import java. text. simpleDateFormat; import java. util. date; import org. apache. commons. lang3.StringUtils;/*** generate the serial number tool class * @ version V1.0 * @ date: 5:21:37 */public class SerialNum {
There are many ways to create multithreading in Java, here's a quick comb1. Inheriting the thread classInherit the Java.lang.Thread class, create a local multithreaded class, overload the Run () method, and invoke the thread's method to start the threads. The sample code is as follows:Mythread.javaPublicClassMyThreadExtendsThread {PublicvoidRun () {Privateint copy =0; System.out.println ("Thread ID:" + thread.currentthread (). GetName () +"= = Print Time:" + system.currenttimemillis ()); System.
There are currently three types of SQL Server wildcard characters, "%", "_", "[charlist]", and three are used for fuzzy queries.The following are presented separately:1, "%""%" is used for any string containing 0 or more characters, instead of the indeterminate part of the query condition, in general, the% wildcard is used to match the following characters, and is a full-text search with a slower speedExample: SELECT * from PRODUCEDATATB WHERE serialnum
) { // 那么按照添加到队列的序列号顺序来执行 return request1.serialNum - request2.serialNum; }}The reverse load is:/** * Reverse load policy, which is loaded from the last request to join the queue * * @author mrsimple */ public class reversepolicy implements loadpolicy { @Override public int compare (Bitmaprequest request1, Bitmaprequest request2) {//note bitmap request to perform the latest qu
Function ConfirmDel ()
{If (confirm ("are you sure you want to delete it? Once deleted, it cannot be restored! "))
Return true;ElseReturn false;}I use one.
Function ConfirmReset ()
{If (confirm ("are you sure you want to cancel the operation? Once canceled, the operation cannot be restored! "))
Window. form1.reset ();// Return true;}
32. indexOf () Usage
This method finds the
Eg. Str. indexOf ("AP")>-1 indicates that the "AP" string exists in str.
33. Generate the serial number
If request. fo
, BitmapRequest request2);}
Because our request queue uses the priority queue PriorityBlockingQueue, our BitmapRequest implements the Comparable interface. In the BitmapRequest function, compareTo is delegated to the compare of the LoadPolicy object.
@Override public int compareTo(BitmapRequest another) { return mLoadPolicy.compare(this, another); }
Let's take a look at the default load policy, that is, loading in order. Requests first added to the queue are first executed.
/***
is similar.
The use of threadlocal
If you want thread-local variables to initialize other values, you need to implement threadlocal subclasses of your own and override the method, typically using an internal anonymous class to subclass Threadlocal, such as the following example, where the Serialnum class assigns an ordinal number to each class:
public class Serialnum
{
The next serial number to be assig
Skills
confirm Operation
function Confirmdel (){if (confirm) are you sure you want to delete it? Once deleted will not be restored! "))return true;Elsereturn false;}
==============================================================
I use one myself.function Confirmreset (){if (Confirm (OK) cancel operation? Once the cancellation operation will not be restored! "))Window.form1.reset ();return true;}
indexOf () usage
This method looks for eg. Str.indexof ("AP") >-1 description of
Import java.awt.Dimension;Import Java.awt.Rectangle;Import Java.awt.Robot;Import Java.awt.Toolkit;Import Java.awt.image.BufferedImage;Import Java.io.File;
Import Javax.imageio.ImageIO;
/******************************************************************** This javabean can be invoked directly in other Java applications to achieve a "picture" of the screen* This JavaBean are used to snapshot the GUI in a* Java application! You can embeded* It in to your Java application source code, and US* It to
1. Read the hard drive serial number
function GetDiskSerial(DiskChar: Char): string; var SerialNum : pdword; a, b : dword; Buffer : array [0..255] of char; begin result := ""; if GetVolumeInformation(PChar(diskchar+":\"), Buffer, SizeOf(Buffer), SerialNum, a, b, nil, 0) then Result := IntToStr(SerialNum^); end;
2. Check to see if the disk is ready
Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.